﻿//vs
//#version 150 core

in vec3 inPosition;
in vec3 inColor;

uniform mat4 mvpMat;

out vec3 passColor;

void main(void) {
    // transform vertex' position from model space to clip space.
    gl_Position = mvpMat * vec4(inPosition, 1.0);

    passColor = inColor;
}

//fs
//#version 150

in vec3 passColor;

out vec4 outColor;

void main(void) {
    outColor = vec4(passColor, 1.0);
}

//gl_VertexID.vs
// vertex shader that gets color value according to gl_VertexID.
//#version 150 core

in vec3 inPosition;
out vec4 passColor;
uniform mat4 mvpMat;

void main(void) {
    // transform vertex' position from model space to clip space.
    gl_Position = mvpMat * vec4(inPosition, 1.0);

    // gets color value according to gl_VertexID.
    int index = gl_VertexID;
    passColor = vec4(
        float(index & 0xFF) / 255.0,
        float((index >> 8) & 0xFF) / 255.0,
        float((index >> 16) & 0xFF) / 255.0,
        float((index >> 24) & 0xFF) / 255.0);
}

//gl_VertexID.fs
//#version 150

in vec4 passColor;

out vec4 outColor;

void main(void) {
    outColor = passColor;
}
